#ifndef TRIAL_GPIOEX_H
#define TRIAL_GPIOEX_H
#include "stm32f1xx_hal.h"


typedef enum {
    NoneEdge=0u,
    RisingEdge,
    FallingEdge,
}GPIO_Trigger_Edge;

/**
 * @brief 区分GPIO 中断触发信号来源  GPIO_MODE_IT_FALLING / GPIO_MODE_IT_RISING
 * @note 此法不适用于脉冲周期小于中断响应时间的情况
 * */
GPIO_Trigger_Edge GPIO_Pin_IT_Trigger_Event(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
{
    GPIO_PinState bitStatus;
    GPIO_Trigger_Edge edge=NoneEdge;
    bitStatus = HAL_GPIO_ReadPin(GPIOx,GPIO_Pin);
    if(bitStatus==GPIO_PIN_SET){
        edge = RisingEdge;
    }
    else if(bitStatus==GPIO_PIN_RESET){
        edge = FallingEdge;
    }

    return edge;
}
#endif //TRIAL_GPIOEX_H
